package cn.edu.ctbu.test.dao;

import cn.edu.ctbu.test.domain.Course;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface CourseRepository extends JpaRepository<Course,Long> {

    @Query("select c from course as c where c.courseName like %?1%")
    List<Course> findByCourseName(String courseName);

    @Query("select c from course as c where c.courseName like %?1%")
    Page<Course> findByCourseName(String courseName, Pageable pageable);

    List<Course> findAll(Specification<Course> scoreSpecification);
    Page<Course> findAll(Specification<Course> scoreSpecification, Pageable pageable);

    Integer count(Specification<Course> scoreSpecification);

}
